define(['map'], function(map) {
    'use strict';

    function Pie(matadata) {
        this.matadata = matadata;
        this.echartslayer = new ol3Echarts(null, {
            hideOnMoving: true,
            hideOnZooming: true
        });
        this.echartslayer.appendTo(map.getMap());
    }

    Pie.prototype.setMateData = function (matadata) {
        this.matadata = matadata;
    }

    Pie.prototype.init = function () {
        this.options = {
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                left: 'right',
                data: [],
                textStyle: {
                    color: '#fff',
                    fontSize: 14
                },
            },
            grid: [],
            series: []
        };
        this.options["legend"]["data"] = this.matadata["legend_data"];
        this.matadata["series_zqInfo_data"].forEach(item => {
            let serie = {
                name: this.matadata["pie_name"],
                type: 'pie',
                radius : item["pie_radius"],
                coordinates: item["coordinate"],
                data: item["data"],
                itemStyle: {
                  emphasis: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                  }
                }
            }
            this.options["series"].push(serie)
        })
        this.echartslayer.setChartOptions(this.options);
    }

    Pie.prototype.setVisible = function (bool) {
        this.echartslayer.setVisible(bool);
    }

    Pie.prototype.destory = function () {
        this.echartslayer.remove();
    }

    return Pie
});